#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int mods=998244353, man=1000000;

class Matrix {
public:
  int n, m;
  ll v[3][3];

  void one(int n) {
    this->n = m = n;
    memset(v, 0, sizeof v);
    for (int i=0; i<n; i++) {
      v[i][i] = 1;
    }
  }

  void trans() {
    n = m = 3;
    memset(v, 0, sizeof v);
    v[0][0] = v[2][1] = v[0][2] = 1;
    v[1][2] = v[2][2] = 2;
  }

  void init() {
    n=1, m=3;
    memset(v, 0, sizeof v);
    v[0][0]=3, v[0][2]=1;
  }

  void mul(Matrix &a, Matrix &b) {
    n=a.n, m=b.m;
    for (int i=0; i<n; i++) {
      for (int j=0; j<m; j++) {
	v[i][j] = 0;
	for (int k=0; k<a.m; k++) {
	  v[i][j] = (v[i][j]+a.v[i][k]*b.v[k][j]%mods)%mods;
	}
      }
    }
  }

  void qpower(ll n) {
    static Matrix s[2], a[2];
    if (!n) {
      return;
    }
    a[0] = *this, s[0].one(m);
    int i=0, j=0;
    for (; n>1; n>>=1) {
      if (n&1) {
	s[!j].mul(s[j], a[i]);
	j = !j;
      }
      a[!i].mul(a[i], a[i]);
      i = !i;
    }
    mul(a[i], s[j]);
  }
};

int main() {
  freopen("riemannian.in", "r", stdin);
  freopen("riemannian.out", "w", stdout);

  static Matrix f[man+1], g[man+1], init, ans, trans;
  init.init();
  f[1].trans();
  f[0].one(3);
  for (int i=2; i<=man; i++) {
    f[i].mul(f[i-1], f[1]);
  }
  g[0].one(3);
  g[1] = f[man];
  for (int i=2; i<=man; i++) {
    g[i].mul(g[i-1], g[1]);
  }

  int t;
  scanf("%d", &t);
  ll ans1=0, ans2=0;
  for (int i=1; i<=t; i++) {
    ll n;
    scanf("%lld", &n);
    n--;
    trans.mul(g[n/man], f[n%man]);
    ans.mul(init, trans);
    ans1 ^= ans.v[0][2];
    ans2 ^= (ans.v[0][1]+ans.v[0][2]+1)%mods;
  }
  printf("%lld %lld", ans1, ans2);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
